/**
 * ROOT - br.com.geropder.sig.util
 * 
 */
package br.com.geropder.sig.util;

import java.io.Serializable;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

/**
 * @author felipe.queis
 * @since 24/07/2012 - 18:08:43
 * 
 */
public class HibernateUtil implements Serializable {
	private static final long serialVersionUID = 1L;

	private static final SessionFactory SESSION_FACTORY = buildSessionFactory();

	private static SessionFactory buildSessionFactory() {

		try {
			return new Configuration().configure("hibernate.cfg.xml")
					.buildSessionFactory();
		} catch (Throwable e) {
			System.out.println("Erro ao criar session factory.\nErro: "
					+ e.getMessage());

			throw new ExceptionInInitializerError();
		}
	}

	public static SessionFactory getSessionFactory() {
		return SESSION_FACTORY;
	}
}